<div class="layui-fluid nepadmin-pad0 nepadmin-mar0 list0" id="list" lay-title="充值记录">
	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-md12">
				<div class="layui-card hxr-layui-card" id="memberlistv">
					<div class="layui-form hxradmin-card-header">
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">会员姓名</label>
								<div class="layui-input-inline">
									<input type="text" name="user" autocomplete="off" class="layui-input">
								</div>
							</div>
							<!-- <div class="layui-inline">
								<label class="layui-form-label">支付方式</label>
								<div class="layui-input-inline">
									<input type="text" name="type" autocomplete="off" class="layui-input">
								</div>
							</div> -->
							<div class="layui-inline">
								<label class="layui-form-label" style='width:85px;'>支付日期范围</label>
								<div class="layui-input-inline">
									<input type="text" name="val2" id='date' autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">支付状态</label>
								<div class="layui-input-inline">
									<div class="layui-unselect layui-form-select">
										<div class="layui-select-title"><input name="status" type="text" value="" readonly class="layui-input layui-unselect"><i
											 class="layui-edge"></i></div>
										<dl class="layui-anim layui-anim-upbit" style="">
											<dd lay-value="" class="layui-select-tips layui-this">选择状态</dd>
											<dd data='1'>已支付</dd>
											<dd data='2'>未支付</dd>
											<dd data='3'>已退款</dd>
										</dl>
									</div>
								</div>
							</div>
							<div class="layui-inline">
								<button class="layui-btn" data-type="reload" id="search">搜索</button>
							</div>
							<div class="layui-inline">
								<button class="layui-btn" data-type="excel" id="pexcel">导出数据</button>
							</div>
						</div>
					</div>
					<div class="layui-card-body">
						<table class="layui-hide" id="list-table" lay-filter="list-table"></table>
                    <div id="list-toolbar" style="display: none;">
						{{#  if(d.status === 1){ }}
						<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="return"><i class="layui-icon layui-icon-list"></i>退款</button>
						{{#  } }}
			        </div>
					</div>
				</div>
				<script type="text/html" id="pay_status">
				  {{#  if(d.status === 1){ }}
					<span class="layui-badge layui-bg-green">已支付</span>
				  {{#  } else if(d.status === 2) { }}
				    <span class="layui-badge">未支付</span>
				  {{#  } else if(d.status === 3) { }}
				    <span class="layui-badge">已退款</span>
				  {{#  } }}
				</script>
			</div>
		</div>
	</div>
</div>
<script>
	var formurl='member/memberform',formarea=['500px', '600px'];
	//表格数据渲染
	layui.use(['table', 'form','laydate'], function() {
		var table = layui.table,
			form = layui.form,
			$ = layui.$,laydate=layui.laydate;
			//日期范围
			  laydate.render({
			    elem: '#date'
			    ,range: true
			  });
			layui.admin.initlist(table,'members/recharge_list',240,[
				[{
					field: 'recharge_id',
					title: 'ID',
					width: 60
				},{
					field: 'recharge_sn',
					title: '支付单编号',
					width: 200
				},{
					field: 'real_name',
					title: '会员姓名',
					minwidth: 100
				},{
					field: 'pay_money',
					title: '支付金额(元)',
					width: 110
				},{
					field: 'give_money',
					title: '赠送金额(元)',
					width: 110
				},{
					field: 'pay_name',
					title: '支付方式',
					width: 150
				},{
					field: 'status',
					title: '支付状态',
					width: 150,
					templet:'#pay_status'
				},{
					field: 'create_time',
					title: '创建时间',
					width: 200
				},{
					field: 'refund_time',
					title: '退款时间',
					width: 200
				},{
					field: 'pay_time',
					title: '支付时间',
					width: 200
				},{
					title: '操作',
					toolbar: '#list-toolbar',
					width: 120,
					fixed:'right'
				}]
			])
		//监听表格表单操作
		form.on('switch(list-tableF)', function(obj) {
			var json = JSON.parse(decodeURIComponent($(this).data('json')));
			json = table.clearCacheKey(json);
			// json.member_status == 1 ? json.member_status = 2 : json.member_status = 1;
			layui.admin.ajax('members/update_member', json).then((res) => {
				layui.admin.ahint(res.code,res.msg);
				layui.table.reload('list-table');
			}).catch((res) => {});
		});
		//监听表格操作事件
		table.on('tool(list-table)', function(obj) {
			var data = obj.data;
			//删除
			if (obj.event === 'return') {
				layer.confirm('确定退款?', function(index) {
					layui.admin.delF(table,'members/recharge_refund',{recharge_id: data.recharge_id});
				});
			} 
		});
		$('#search').on('click', function() {
			var val1 = $('input[name="user"]').val(),
			val2 = $('input[name="val2"]').val(),
			type = $('input[name="type"]').val(),
			status = $('input[name="status"]').attr('data');
			layui.admin.reloads({
				search_text:val1,
				datemin:val2.split(' ')[0],
				datemax:val2.split(' ')[2],
				type:type,
				status:status
			});
		});
		//导出
		$('#pexcel').on('click', function() {
			var val1 = $('input[name="user"]').val(),
					val2 = $('input[name="val2"]').val(),
					type = $('input[name="type"]').val(),
					status = $('input[name="status"]').attr('data');
			layui.admin.excel(table,'members/recharge_list',
					{
						search_text:val1,
						datemin:val2.split(' ')[0],
						datemax:val2.split(' ')[2],
						type:type,
						status:status
					},'');
		});
	});
</script>
